package sjms.create.singleton;

public class Singleton_2 {
    public static void main(String[] args) {

    }
}

/**
 * 饿汉式——2
 * 优缺点同饿汉式——1相同，只不过将静态实例的初始化放入了静态代码块中
 */

class Singleton{

    private static Singleton instance;

    private Singleton(){}

    static{
        instance = new Singleton();
    }

    public static Singleton getInstance(){
        return instance;
    }
}
